<?php


namespace App\Utils\Lib\Mortgage;


class SecondMethod implements MakerMortgage
{
    public function MakeMortgageInterface($money)
    {
        $dkm   = 12; //贷款月数，20年就是240个月
        $dkTotal = $money; //贷款总额
        $dknl  = 0.049; //贷款年利率
        $em   = $dkTotal / $dkm; //每个月还款本金
        $lxTotal = 0; //总利息
        for ($i = 0; $i < $dkm; $i++) {
            $lx   = $dkTotal * $dknl / 12; //每月还款利息
            $dkTotal -= $em;
            $lxTotal = $lxTotal + $lx;
            $count[]= ["第" . ($i + 1) . "期", " 本金:". $em, " 利息:" . $lx, " 总额:" . $em];
        }
        return $count;
        echo "总利息:" . $lxTotal;
    }

}
